import { drizzle } from "drizzle-orm/mysql2";
import mysql from "mysql2/promise";
import { relations } from 'drizzle-orm';
import { students,posts,comments } from "../db/schema.js";

const connection = await mysql.createConnection({
  host: "localhost",
  user: "root",
  password: "1234",  // 需要添加密码
  database: "study"  // 您的数据库名
});

const db = drizzle({ client: connection, schema: { students,posts,comments },mode: 'default'  });
// const users = await db.query.students.findMany();
//  const users = await db.query.students.findMany(
//     {
// 	columns: {
// 		name: true,
// 		phone: false //ignored
// 	},
// }
//  );
const postspp = await db.query.posts.findMany({
	with: {
		comments: true,
	},
});
console.log(postspp,'postspp');
